﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace WpfApp7.Command
{
    public class wpf7Command : ICommand
    {
        public event EventHandler CanExecuteChanged;

        private readonly Action _action;    //要执行的业务逻辑
        private readonly Action<object> _action1;    //要执行的业务逻辑

        public wpf7Command(Action action)
        {
            _action = action;
        }

        public wpf7Command(Action<object> action1)
        {
            _action1 = action1;
        }

        public bool CanExecute(object parameter) => true;

        /// <summary>
        /// 要执行的业务逻辑
        /// </summary>
        /// <param name="parameter"></param>
        public void Execute(object parameter)
        {
            _action?.Invoke();
            _action1?.Invoke(parameter);
        }
    }
}
